package com.chain.qs.modules.biz.aspect;

import com.chain.qs.modules.biz.service.BasicInfoService;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;

import javax.annotation.Resource;

/**
 * 及时更新缓存
 * Created by fgx on 2016/11/11.
 */
@Aspect
public class RefreshCacheAspect {
    @Resource
    private BasicInfoService basicInfoService;

    // 监测告警规则变化
    @AfterReturning("execution(* com.chain.qs.modules.biz.web.EquipmentItemWarningRuleController.save(..)) || execution(* com.chain.qs.modules.biz.web.EquipmentItemWarningRuleController.delete(..))")
    public void refreshWarningRuleUpdate() {
        basicInfoService.refreshWarningRuleMapInfoCache();
        basicInfoService.refreshGetExistWarningMap();
    }

    // 监测告警记录变化
    @AfterReturning("execution(* com.chain.qs.modules.biz.service.WarningRecordService.save(..)) || execution(* com.chain.qs.modules.biz.service.WarningRecordService.delete(..))")
    public void refreshWarningRecordUpdate() {
        basicInfoService.refreshWarningRecordMapInfoCache();
        basicInfoService.refreshGetExistWarningMap();
    }

    // 监测设备和设备类型变化
    @AfterReturning("execution(* com.chain.qs.modules.biz.web.EquipmentGroupItemController.save(..)) || execution(* com.chain.qs.modules.biz.web.EquipmentGroupItemController.delete(..)) || execution(* com.chain.qs.modules.biz.web.EquipmentController.delete(..)) || execution(* com.chain.qs.modules.biz.web.EquipmentController.delete(..))")
    public void refreshFindAvailableDeviceIdAndEquipKid() {
        basicInfoService.refreshFindAvailableDeviceIdAndEquipKid();
        basicInfoService.refreshFindAvailableDevice();
        basicInfoService.refreshFindAvailableDeviceIdAndTypeId();
        basicInfoService.refreshFindAvailableDeviceIdKeyword();
        basicInfoService.refreshGetExistWarningMap();
    }

    // 监测参数变化
    @AfterReturning("execution(* com.chain.qs.modules.biz.web.EquipmentParamentsController.save(..)) || execution(* com.chain.qs.modules.biz.web.EquipmentParamentsController.delete(..))")
    public void refreshFindAvailableParam() {
        basicInfoService.refreshFindAvailableParamIdName();
        basicInfoService.refreshFindAvailableParam();
        basicInfoService.refreshGetExistWarningMap();
    }

    // 监测站组变化
    @AfterReturning("execution(* com.chain.qs.modules.biz.web.StationGroupController.save(..)) || execution(* com.chain.qs.modules.biz.web.StationGroupController.delete(..))")
    public void refreshFindAvailableSgrp() {
        basicInfoService.refreshFindAvailableSgrp();
        basicInfoService.refreshGetExistWarningMap();
    }


    // 监测站点变化
//    @AfterReturning("execution(* com.chain.qs.modules.biz.web.StationController.save(..)) || execution(* com.chain.qs.modules.biz.web.StationController.delete(..))")
//    public void refreshAvailableStationUpdate() {
//        basicInfoService.refreshAvailableStation();
//        basicInfoService.refreshAvailableStationIdCode();
//        basicInfoService.refreshProvinceJs();
//    }

    @AfterReturning("execution(* com.chain.qs.modules.sys.web.OfficeController.save(..)) || execution(* com.chain.qs.modules.sys.web.OfficeController.delete(..))")
    public void refreshAvailableOfficeUpdate() {
        basicInfoService.refreshFindGradeFourAvailableOffice();
        basicInfoService.refreshGetExistWarningMap();
    }


    // 监测字典变化
//    @AfterReturning("execution(* com.chain.qs.modules.sys.web.DictController.save(..)) || execution(* com.chain.qs.modules.sys.web.DictController.delete(..))")
//    public void refreshAvailableDictItemTypeUpdate() {
//        basicInfoService.refreshAvailableDictItemType();
//    }

}
